// JavaScript Document
//需要jquery.js
//去掉html默认文档标示
//write by lijianwei  2010-01-17
document.write("<style>");
document.write(".smallnum{text-align:right;height:20px;width:100%;position:absolute;bottom: 15px;padding-right:15px;}");
document.write(".alink{margin-right:10px;width:30px;}");
document.write(".blink{margin-right:10px;width:30px;}");
document.write("a.alink:link,a.alink:active,a.alink:visited,a.alink:hover{text-decoration: none;line-height:20px;background-color:#E4E4E4;text-align: center;vertical-align: middle;color:red;}");

document.write("a.blink:link,a.blink:active,a.blink:visited,a.blink:hover{line-height: 20px;text-decoration: none;text-align:center;vertical-align:middle;background-color:#000000;color:red;}");
document.write("</style>");
var type=encodeURIComponent("首页幻灯(730*422)"); //设置请求的类型
var u="/e/index.php/index/get_ad";//设置请求的网址
var widths=100; //先初始化宽度和高度,数量,图片信息数组
var heights=100;
var counts=4;
var pic_arr=new Array();//图片数组
var url_arr=new Array();//网址数组
var ad_name_arr=new Array();//文字说明
var flash_time=0;//切换时间
var nn=1;
//通过ajax加载宽度,高度,数量,图片信息数组
$.ajax({
   type:"GET",
   dataType:"json",
   async:false,
   cache:true,
   data:"type="+type,
   url:u,
   success:function(msg){
       msg=eval(msg);
	   widths=msg.width;
	   heights=msg.height;
	   flash_time=msg.flash_time;
	   counts=msg.num;
	   $.each(msg.pic_info,function(i,n){
	         i++;
			 pic_arr[i]=n.ad_pic;
			 url_arr[i]=n.ad_url;
			 ad_name_arr[i]=n.ad_name;
	   });
   }
});
change_img=function(){
   document.getElementById("pic").filters.revealTrans.Transition=23;document.getElementById("pic").filters.revealTrans.apply();
   $("#pic").attr("src",pic_arr[nn]); 
   $("#url").attr("href",url_arr[nn]); 
   $("#url").attr("title",ad_name_arr[nn]);
   for (var i=1;i<=counts;i++){
    $("#num"+i).removeClass();
    $("#num"+i).addClass("alink");
   } 
   $("#num"+nn).removeClass();
   $("#num"+nn).addClass("blink");
   document.getElementById("pic").filters.revealTrans.play();
   nn++;
   if(nn>counts){
     nn=1;
   } 
   tt=setTimeout('change_img()',flash_time); //图片切换速度;
}
changeimg=function(n){
  nn=n;
  window.clearInterval(tt);
  change_img();
}
document.write("<div style='width:"+widths+"px;height:"+heights+"px;overflow:hidden;text-overflow:clip;'>");
document.write("<div><a id='url' href='' target='_blank'><img id='pic'  src='' style='border:0px;filter:revealTrans(duration=2;transition=3);' width='"+widths+"' height='"+heights+"' /></a></div>");
document.write("<div class='smallnum'>");
for(var i=1;i<=counts;i++){
document.write("<a href='javascript:changeimg("+i+");' id='num"+i+"' class='alink'>"+i+"</a>");
}
document.write("</div></div>");
change_img();

